<%@ page language="java" pageEncoding="UTF-8"
	contentType="text/html; charset=UTF-8"%>
<%@ page import="com.mymail.entity.*"%>
<%!String register(String username, String password, String email) {
		User user = new User();
		user.setName(username);
		user.setPassword(password);
		user.setEmail(email);
		int result = user.addToDatabase();
		switch (result) {
		case User.UNKNOW_ERROR:
			return "注册失败,系统错误";
		case User.NAME_EXIST:
			return "注册失败,该用户已存在";
		case User.EMAIL_EXIST:
			return "该邮箱已经注册,请用其它邮箱注册";
		default:
			return "OK";
		}
	}
%>
<%
	String username = request.getParameter("username");
	String password = request.getParameter("password");
	String email = request.getParameter("email");
	String code = request.getParameter("code");
	if (code.toUpperCase().equals(session.getAttribute("code"))) {
		out.print("验证码错误，请重新填写验证码");
	} else {
		out.print(register(username, password, email));
	}
	session.removeAttribute("code");
%>